package com.onlyxiahui.common.utils.extend.change;

import java.util.List;
import java.util.Map;

import com.onlyxiahui.common.utils.base.compare.DifferentValueUtil.Different;

/**
 * 
 * Description <br>
 * Date 2020-11-09 19:01:58<br>
 * 
 * @author XiaHui [onlovexiahui@qq.com]<br>
 * @since 1.0.0
 */
public class UpdateFormatImpl implements UpdateFormat {

	@Override
	public String getContent(Map<String, String> propertyDescribeMap, List<Different> list) {
		StringBuilder sb = new StringBuilder();
		if (null != list) {
			for (Different d : list) {
				String name = d.getOldName();
				String text = (null != propertyDescribeMap) ? propertyDescribeMap.get(name) : "";
				text = null == text ? "" : text;
				sb.append(text);
				sb.append("(");
				sb.append(name);
				sb.append("):");
				sb.append("从[");
				sb.append(d.getOldValue());
				sb.append("]修改为[");
				sb.append(d.getNewValue());
				sb.append("]；");
				sb.append("\n");
			}
		}
		return sb.toString();
	}
}
